// services/storageManager.js
const STORAGE_KEY = 'requestData';

const getRequestData = () => {
  const data = localStorage.getItem(STORAGE_KEY);
  return data ? JSON.parse(data) : { count: 0, timestamp: Date.now() };
};

const saveRequestData = (count, timestamp) => {
  const data = { count, timestamp };
  localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
};

const resetRequestData = () => {
  const now = Date.now();
  const data = { count: 0, timestamp: now };
  localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
};

export { getRequestData, saveRequestData, resetRequestData };
